import java.util.Arrays;
import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/4/15 21:21
 */

public class Solution {
    public void rotate(int[] nums, int k){
        int n = nums.length;
        k %= n;

        reverse(nums, 0, n - k - 1);
        reverse(nums, n - k, n - 1);
        reverse(nums, 0, n - 1);
    }

    private void reverse(int[] nums, int begin, int end) {
        while (begin < end) {
            int temp = nums[begin];
            nums[begin] = nums[end];
            nums[end] = temp;
            begin++;
            end--;
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int len = in.nextInt();
            int[] nums = new int[len];
            for (int i = 0; i < len; i++) {
                nums[i] = in.nextInt();
            }
            int k = in.nextInt();
            Solution solution = new Solution();
            solution.rotate(nums,k);
            System.out.println(Arrays.toString(nums));
        }
    }
}
